import {
  put,
  takeLatest,
  all,
  call,
} from 'redux-saga/effects'
import { projectLabelView as projectDuck } from 'ducks'
import getProjectLabelView from 'graphql/getProjectLabelView.graphql'
import { gqlQuery } from './utils'

function* getProjectLabelViewSaga(action) {
  const result = yield call(gqlQuery, getProjectLabelView, { id: action.projectId })
  console.log(result.projectLabelView)
  yield put(projectDuck.creators.actionReciveProjectInfo(result.projectLabelView))
}

export default function* sagas() {
  yield all([
    takeLatest(projectDuck.types.LOAD_INFO, getProjectLabelViewSaga),
  ])
}
